/**
 * 公开认证路由模块 - 不需要认证Token的路由
 */

const express = require('express');
const publicAuthController = require('../controllers/publicAuthController');
const { verifyCaptchaMemory } = require('../middlewares/captchaMemory');
const { authenticateRefreshToken } = require('../middlewares/authMiddleware');

const router = express.Router();

// 用户登录 
router.post('/login', verifyCaptchaMemory, publicAuthController.login);

// Token刷新路由
router.patch('/refresh', authenticateRefreshToken, publicAuthController.refresh);

// 获取验证码
router.get('/captcha', publicAuthController.captchaImage);

// 获取验证码状态（开发环境调试用）
router.get('/captcha/status', publicAuthController.getCaptchaStatus);

// 清理验证码（开发环境调试用）
router.delete('/captcha/clear', publicAuthController.clearCaptcha);

// 健康检查
router.get('/health', publicAuthController.health);

// 监控上报
router.post('/report', publicAuthController.report);

// SSE公共连接路由（无需认证）
router.get('/sse/public', publicAuthController.connectPublic);

// 监控相关公开路由
router.post('/monitor/report', publicAuthController.reportMonitorData);
router.get('/monitor/health', publicAuthController.monitorHealth);

// Sourcemap相关公开路由
router.get('/sourcemap/:filename', publicAuthController.getSourcemap);
router.get('/sourcemap/status/check', publicAuthController.checkDebugStatus);

module.exports = router;